// pages/protected-page.js
"use client";

import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { getUserAccount } from "../../utils/defender";
import { message } from "antd";

function AuthCO({ children }: { children: React.ReactNode }) {
  const router = useRouter();

  useEffect(() => {
    if (!getUserAccount()) {
      // 如果用戶未登錄，重定向到登錄頁
      message.info('請先登錄')
      router.push("/");
    }
  }, [router]);

  return (
    <>
      {children}
    </>
  );
}

export default AuthCO;
